package work.chenbo.springboot.security.config;

import lombok.Data;

/**
 * @author ChenBo
 * @className SimpleResponse
 * @date 2020/11/5
 */
@Data
public class SimpleResponse {

    private final static int SUCCESS_CODE = 1;
    private final static int FAIL_CODE = 0;
    private Object data;
    private int code;
    private String msg;
    private SimpleResponse(int code, String msg, Object data){
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static SimpleResponse getSuccess(){
        return new SimpleResponse(SUCCESS_CODE,"成功",null);
    }

    public static SimpleResponse getSuccess(Object data){
        return new SimpleResponse(SUCCESS_CODE,"成功",data);
    }

    public static SimpleResponse getSuccess(String msg,Object data){
        return new SimpleResponse(SUCCESS_CODE,msg,data);
    }

    public static SimpleResponse getFail(String msg){
        return new SimpleResponse(FAIL_CODE,msg,null);
    }

    public static SimpleResponse getFail(String msg,Object data){
        return new SimpleResponse(FAIL_CODE,msg,data);
    }



}
